<template>
	<view class="page" style="padding-bottom: 40rpx;">
		<view class="message">
			<view class="message-item" v-for="(item,index) in datas" :key="index" @click="tabfun(item,index)">
				<view class="message-title flex">
					<view style="width: 580rpx;">{{item.title}}</view>
					<text class="tn-icon-down" v-if="!item.is_show" style="font-size: 30rpx;color: #999999;"></text>
					<text class="tn-icon-up" v-else style="font-size: 30rpx;color: #999999;"></text>
				</view>
				<view class="message-timer">{{item.create_time}}</view>
				<view class="message-content" v-if="item.is_show" v-html="acitem.content"></view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				apifun:this.apifun,
				id:'',
				page: 1,
				limit: 10,
				datas: [],
				acnavdata:{},
				acitem:{}
			}
		},
		onLoad(option) {
			this.id = option.id;
			this.initData();
		},
		methods: {
			tabfun(item,index){
				if(item.id == this.acnavdata.id){
					this.$set(this.acnavdata,'is_show',false);
					this.acnavdata = {};
					return false;
				};
				this.datas.forEach((items,indexs)=>{
					this.$set(items,'is_show',false)
				});
				this.acnavdata = item;
				this.$set(item,'is_show',true);
				this.noticexq(item.id);
			},
			noticexq(id){
				let sendData = {
					id:id
				};
				this.apifun.unirequest('/partner/index/getNewNoticeDetail','post',sendData,(res)=>{
					if(res.code === 200){
						let datas = res.data;
						this.acitem = datas
					}else{
						this.apifun.toast(res.msg)
					}
				})
			},
			initData(){
				let params = {
					page: this.page,
					limit:this.apifun.limit
				}
				this.apifun.unirequest('/partner/index/getNewNotice','post',{},(res)=>{
					if(res.code === 200){
						let datas = res.data;
						this.datas = datas;
					}else{
						this.apifun.toast(res.msg)
					}
				})
			}
		},
		onReachBottom() {
			
		},
		onPullDownRefresh() {
			this.page = 1
			this.datas = [];
			this.initData();
			uni.stopPullDownRefresh();
		}
	}
</script>

<style scoped lang="scss">
	.message {
		margin: 20rpx 30rpx;

		.message-item {
			border-radius: 20rpx;
			opacity: 1;
			background: #FFFFFF;
			margin-bottom: 20rpx;
			padding: 30rpx;
			box-sizing: border-box;

			.message-title {
				font-size: 30rpx;
				font-weight: bold;
			}

			.message-timer {
				margin-top: 20rpx;
				font-size: 24rpx;
				padding-bottom: 10rpx;
				color: #999999;
			}
			.message-content{
				border-top: 2rpx solid #F1F1F1;
				padding-top: 20rpx;
				// padding: 28rpx 20rpx 16rpx 19rpx;
				box-sizing: border-box;
				font-size: 24rpx;
				color: #9E9E9E;
			}
		}
	}
</style>